﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_Hsxm_Edit.aspx.vb" Inherits="PubProject.Cwjk_Hsxm_Edit" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>辅助核算设置</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
		<link rel="stylesheet" type="text/css" href="/_nav/nav.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
		<script language="javascript" src="/_controls/settings.aspx"></script>
		<script language="javascript" src="/_controls/setting.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/datetime/time.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookup.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookupDialogs.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="/_common/scripts/global.js"></script>		
		<!-- workflow -->
		<script language="javascript" src="/MyWorkflow/workflow.js"></script>
		<script language="javascript" src="/slxt/js/Public.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
		<script language="javascript">
		//在线帮助文件
		    var _MyHelpfile = "/Cbgl/Help/topics/财务人员/设置财务接口/设置辅助核算.html";
		
	    // 初始化界面
		function window.onload()
		{
		    var sCwztName = "";
		    
		    if (!document.getElementById("__CwztName") || document.getElementById("__CwztName").value=="")
			{
			    alert("请选择账套！");
			    return;
			}
			
			var sPath = "/PubProject/Cwjk/Cwjk_XMLHTTP.aspx?CwztGUID="+ appForm.CwztGUID.value;
		    var sResult = openXMLHTTP(sPath,"GetSoftVesionByCwztGUID");
		    var arrResult = sResult.split('|');

		    if (arrResult.length==2 && arrResult[0]=="YES" && arrResult[1]=="用友 U8.71")
            {
			    HideShowElement("HsTypeNameU8","select","");
			}
			else
			{
			    HideShowElement("HsTypeNameU8","select","none");
			}

			if (document.all("__Application") && document.all("__Application").value == "0101") {
			    _MyHelpfile = "/Slxt/HELP/topics/财务管理/财务接口设置/设置辅助核算.html";
			}
			
        }
					
		//保存数据
		function Save()
		{   
		    if (CheckAppFromValue()!=false)
		    {
		        appForm.Save();
		    }
		}		
		
		//保存并关闭
		function SaveAndNew()
		{
		     if (CheckAppFromValue()!=false)
		     {
		        appForm.SaveAndNew();
		     }
		}
		
		//保存并关闭
		function SaveAndClose()
		{
		     if (CheckAppFromValue()!=false)
		     {
		        appForm.SaveAndClose();
		     }
		}
		
		function CheckAppFromValue()
		{
		    return true;
		}

		function oprBeforeSave()
		{
			if (appForm.CwztGUID.value=="")
			{
			    alert("请选择账套！");
			    event.returnValue = false;
			    return;
			}
			
			var sPath = "";
			var sResults = "";
			
			if (appForm.OperObject.value!="" && appForm.OperObject.value!="手工录入" &&  appForm.appForm_OperObject_Old.value!=appForm.OperObject.value)
			{
			    sPath = "/PubProject/Cwjk/Cwjk_XMLHTTP.aspx?CwztGUID=" + appForm.CwztGUID.value + "&OperObject="+ escape(appForm.OperObject.value);

	            sResults = openXMLHTTP(sPath,"CheckHsxmOperObjectIsRepeated");
	            
	            if (sResults.split('|')[0]=="YES")
                {
                    alert("业务对象重复，请重新录入");
                    event.returnValue = false;
			        return;
                }
			}
			
			if (appForm.HsTypeName.value!="" && appForm.appForm_HsTypeName_Old.value!=appForm.HsTypeName.value)
			{
			    sPath = "";
			    sResults = "";
			    
			    sPath = "/PubProject/Cwjk/Cwjk_XMLHTTP.aspx?CwztGUID=" + appForm.CwztGUID.value + "&HsTypeName="+ escape(appForm.HsTypeName.value);
	            sResults = openXMLHTTP(sPath,"CheckHsxmHsTypeNameIsRepeated");
	            
	            if (sResults.split('|')[0]=="YES")
                {
                    alert("核算方式重复，请重新录入");
                    appForm.HsTypeName.focus();
                    event.returnValue = false;
			        return;
                }
			}
			
			if (document.getElementById("__mode")!=null && document.getElementById("__mode").value=="2")
			{
			    if (appForm.OperObject.value!="" && appForm.appForm_OperObject_Old.value!=appForm.OperObject.value)
			    {
			        if (confirm("修改业务对象，将删除原辅助核算对应的核算对照，确定要保存修改的结果吗？")==false)
			        {
			            event.returnValue = false;
			            return;
			        }
			        else
			        {
			            sPath = "";
			            sResults = "";
			            
			            sPath = "/PubProject/Cwjk/Cwjk_XMLHTTP.aspx?HsTypeGUID=" + appForm.oid.value;    		    
	                    sResults = openXMLHTTP(sPath,"DeleteCwjkHsxmExcludeSelf");
			        }
			    }
			}
			
			event.returnValue = true;
		}
		
		function oprAfterSave()
		{
		  	var xmlDom = new ActiveXObject("Microsoft.XMLDOM")
		  	
	        try
	        {
		        xmlDom.loadXML(appForm.returnxml);

		        if (xmlDom.documentElement.attributes.getNamedItem("result").value == "true")
	            {
	                appForm.appForm_HsTypeName_Old.value = appForm.HsTypeName.value;
	                appForm.appForm_OperObject_Old.value = appForm.OperObject.value;

	                //保存成功后的相关操作
	                if (xmlDom.documentElement.attributes.getNamedItem("keyvalue").value!="")
	                {
	                    ParentGridRefresh(xmlDom.documentElement.attributes.getNamedItem("keyvalue").value);
	                }
	            }
	            else
	            {
	                //保存失败后的相关操作
	                alert("保存失败，请与系统管理员联系！");
	            }
	        }
	        catch(e)
	        {
		        alert("返回的xml格式错误，请与管理员联系！");
		        return;
	        }
	        
		    event.returnValue = true;
		}
		
		//刷新父窗口页面
		function ParentGridRefresh(sHsTypeGUID)
		{
			//刷新主界面
			try
			{
				window.opener._appGrid_Query(sHsTypeGUID);		// 刷新网格 id="appGrid"
				window.opener.parent.SetReloadBySignName("Kjkmsz");
				window.opener.parent.SetReloadBySignName("Pzgzsz");
			}
			catch(e)
			{
			}
		}		
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<table class="layout" cellSpacing="0" cellPadding="0">
			<COLGROUP>
				<col width="140"> <!-- 导航菜单：140px -->
				<col>
			</COLGROUP>
			<tr height="48" id="trzc">
				<td colSpan="2">
					<!-- 菜单 --><mnu:appformmenu id="appFormMenu" runat="server"></mnu:appformmenu></td>
			</tr>
			<tr>
				<td colSpan="2">
					<div class="area">
						<cnt:AppForm id="appForm" runat="server" DefaultValueXml="" processtype="xmlhttp" assembly="Mysoft.Map.Core" invokeclass="Mysoft.Map.Data.MyDB" invokefunction="SaveXml" onbeforesave="oprBeforeSave()"   onaftersave="oprAfterSave()"></cnt:AppForm>
					</div>
				</td>
			</tr>
		</table>
		<form id="Form1" runat="server">
		</form>
	</body>
</HTML>
